<template>
	<view>
		<image src="https://nc.heizixun.com/static/crowdBg1.png" class="bg" mode="widthFix"></image>
		<view class="code" @click="previewImage">
			<image :src="qrCode"></image>
		</view>
	</view>
</template>

<script>
	import StoreApi from '@/api/store'

	export default {
		data() {
			return {
				qrCode: ''
			}
		},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad() {
			// 获取当前用户信息
			this.getUserInfo()
		},

		methods: {
			// 获取当前用户信息
			getUserInfo() {
				StoreApi.data().then(result => {
					this.qrCode = result.data.storeInfo.qrImage.preview_url
				})
			},
			previewImage(){
				uni.previewImage({
				  urls: [this.qrCode], // 单张图片
				  current: 0, // 默认显示第一张（单张时可以不写）
				});
			}
		},
	}
</script>
<style>
	page {
		background: #fff;
	}
</style>
<style lang="scss" scoped>
	.bg {
		position: absolute;
		width: 100%;
		top: 0;
		left: 0;
	}

	.code {
		width: 240rpx;
		height: 240rpx;
		background: #fff;
		position: absolute;
		top: 660rpx;
		right: 74rpx;
		z-index: 1;
		border-radius: 20rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>